home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / FlickWR1.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  5KB  |  163 lines

  1. /*
  2.    This is the opening phase of the ARexx scripts for making Flicks's
  3.    
  4.    This script gets three things from the user and sticks them into a
  5.    file in ram: so the other three phases of the process will know what
  6.    to do.
  7.    
  8.      1 - The name of the Flick to create or extend is obtained
  9.      2 - The name template to be used for the individual frames is obtained.
  10.      3 - The number of jiffies between frames.
  11.  */
  12. call pragma('stack',20000);
  13.  
  14. /*
  15.  * open rexxsupport.library -- needed for some functions
  16.  */
  17. if ~show('L',"rexxsupport.library") then do
  18.   if addlib('rexxsupport.library',0,-30,0) then do
  19.       /* everything's ok */
  20.     end;
  21.   else do
  22.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  23.     say 'Cannot operate FlickWR.rexx without this library - sorry!';
  24.     exit 10;
  25.     end;
  26.   end;
  27.  
  28. /*
  29.  * This will automatically direct the script to the proper
  30.  * software, if it is running.
  31.  */
  32. prtnme = 'IP_Port'; /* assume Image Professional */
  33. if show('P','IP_Port') = 0 then do
  34.   if show('P','IM_Port') = 0 then do
  35.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  36.     say "This script requires IP, IM or IM F/c to run!";
  37.     exit(20);
  38.     end;
  39.   else do
  40.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  41.     end;                 /* We make em, user's break em.          */
  42.   end;
  43.  
  44. options;
  45. address;
  46.  
  47.   prevpath = 'ram:'; /* put user in ram to start with... */
  48.  
  49.   if show('C',flickpath) = 1 then do
  50.     prevpath = getclip(flickpath);
  51.     end;
  52.  
  53.   address(prtnme);
  54.  
  55.   options results;
  56.   'filerequest "'||prevpath||'","'||bufname||'",".flc","Make Flick"';
  57.   flickfile = result;
  58.   options;
  59.  
  60.   if flickfile = 'FR_CANCELLED' then do
  61.     address(prtnme);
  62.     'imtofront';
  63.     exit 0;
  64.     end;
  65.   else do
  66.     flickfile = expandfilename(flickfile);
  67.     thispath = gimmepath(flickfile);
  68.     call setclip(flickpath,thispath);
  69.   end;
  70.  
  71.   options results;
  72.   'askprop '||'"# of jiffies (60th / sec) between frames?" 2 1 180'
  73.   jiffies = result;
  74.   options;
  75.  
  76.   res = open(fhandle,flickfile,'read');
  77.   if res ~= 0 then do
  78.     call close(fhandle);
  79.     address(prtnme);
  80.     options results;
  81.     'askyn '||'"Create New Flick" "Append to Existing Flick"'
  82.     prefs = result;
  83.     if prefs = 0 then do
  84.       address command 'c:delete >nil: '||flickfile;
  85.       end;
  86.     if prefs = 1 then do
  87.       options results;
  88.       'askyn '||'"Truncate before appending" "Append as is"'
  89.       prefs = result;
  90.       if prefs = 0 then do
  91.         address command 'cmpi:FlickWR -t '||jiffies||' '||flickfile;
  92.         end;
  93.       end;
  94.     end;
  95.  
  96.   address(prtnme);
  97.   options results;
  98.   'askyn '||'"Create loop frame" "No loop frame"'
  99.   prefs = result;
  100.  
  101.   call open(fhandle,'ram:IP_FLICKWR.CFG','write');      /* open the file */
  102.   junk = writeln(fhandle, jiffies);
  103.   junk = writeln(fhandle, flickfile);
  104.   junk = writeln(fhandle, prefs);
  105.   call close(fhandle);                     /* close the file    */
  106.  
  107.   address(prtnme);
  108.   'finish';
  109.   exit 0;
  110.  
  111.  
  112. /*
  113.  * gimmepath
  114.  *
  115.  * This takes the provided argument and sucks the path out of it, then
  116.  * returns that path to the caller, sans file name.
  117.  */
  118. gimmepath:
  119.   arg fullnamegx;
  120.     tempgx = reverse(fullnamegx);
  121.     lengx = length(fullnamegx);   /* get length of string */
  122.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  123.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  124.     seploc = 0; /* assumes current dir, no path supplied */
  125.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  126.       seploc = (lengx - slashdex)+1;
  127.       end;
  128.     else do
  129.       if colondex ~= 0 then do /* we assume we are on a device */
  130.         seploc = (lengx - colondex)+1;
  131.         end;
  132.       end;
  133.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  134.   gxpath = left(fullnamegx,seploc);
  135.   return(gxpath);
  136.  
  137. /*
  138.  * Since this script can't be expected to know where the CD of the user
  139.  * is when this cmd is invoked, we have to check the path the user
  140.  * provides - if it's not specified right from a root, then we have
  141.  * to make it a complete specification from the root.
  142.  */
  143. expandfilename:
  144.   parse arg jfile;
  145.   if index(jfile,':') = 0 then do
  146.     curdir = pragma(D);
  147.     if right(curdir,1) ~= ':' then do
  148.       if right(curdir,1) ~= '/' then do
  149.         if curdir ~= '' then do
  150.           curdir = curdir || '/';
  151.           end;
  152.         end;
  153.       end;
  154.     jfile = curdir||jfile;
  155.     end;
  156.   return(jfile);
  157.  
  158. rvalue:
  159.   wordnum = c2d(readch(fhandle,1)) * 256;
  160.   wordnum = wordnum + c2d(readch(fhandle,1));
  161.   return wordnum;
  162.  
  163.